<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="global.jsp" %>
<%
  int caiGouBiaoId = ParamUtils.getIntParameter(request,"CaiGouBiaoId", -1);
  if (caiGouBiaoId == -1){
	  out.println("参数错误");
      return ;
  }

      //
      CaiGouBiaoJia cgbj = new CaiGouBiaoJia(caiGouBiaoId);
      ArrayList sps = cgbj.GetCaiGouShangPings();
      ArrayList cggss = cgbj.GetCaiGouGongSis();
      int factorys = cggss.size();
      int productorys = sps.size();
      
      //公司个数不足三个时补足三个
      //商品默认5个.
      int xFactorysNeed = 3 - factorys;
      int xProductorysNeed = 5 - productorys;
      
      if(xFactorysNeed < 0)
      {
    	  xFactorysNeed = 0;
      }
      if(xProductorysNeed < 0)
      {
    	  xProductorysNeed = 0;
      }
    	
    	
      int nCaiGouYuanId = cgbj.getYuanGongId();
      User caigouYuan = new User(nCaiGouYuanId);
      String strCaiGoyYuanName = caigouYuan.getXingMing();
	  
	  //int nUserQuanXian = UserManager.GetShenHeYuanQuanXianByUserID(pageUser.getYongHuMing());
      //System.out.println("nUserQuanXian:"+nUserQuanXian); 
	  //常用意见
       String cyyj = XiaLaLiebiaoInfos.getHtmlOption(XiaLaLiebiaoInfos.GetAllYiJian());
	   
	   //审核意见栏的宽度
      int nYiJianWidth = 30+factorys * 12;
    %>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购比价单</title>

<style type="text/css">  
   body{margin:0px;}
   .fontff{
          TEXT-ALIGN:center;                   
   }
   .unbloud{   
            BORDER-RIGHT:   #000000   0px   solid;   BORDER-TOP:   #000000   0px   solid;   BORDER-LEFT:   #000000   0px   solid;   BORDER-BOTTOM:   #000000   1px   solid   
   }
   .unbloud_error{   
            BORDER-RIGHT:   #000000   0px   solid;   BORDER-TOP:   #000000   0px   solid;   BORDER-LEFT:   #000000   0px   solid;   BORDER-BOTTOM:   #ff0000   1px   solid   
   }
   .error{border:1px solid #ff0000;}
   .correct{font-size : 11px;}
   body,td,th,input {
	font-size: 12px;
   }
#productSearch_layer {
	position:absolute;
	padding:20px;
0 20px;	background: #D5D5D5;
	border:1px solid #999999;
	width:522px;
	height:234px;
	left:100px;
	top:138px;
	z-index:2;
}



    </style>
<!--media=print   这个属性可以在打印时有效--> 
<style   media=print> 
.Noprint{display:none;} 
.PageNext{page-break-after:   always;} 
</style> 
<link href="css/basic.css" rel="stylesheet" type="text/css" />
<link href="styleTable.css" type="text/css" rel="Stylesheet" />
<style type="text/css">
<!--
#cyyj {
	position:absolute;
	left:528px;
	top:485px;
	width:149px;
	height:38px;
	z-index:3;
}
-->
</style>
<script type="text/javascript"> 
 function changeval(obj1,obj2) {
   obj2.value = obj1.options[obj1.selectedIndex].value;
}
//显示商品查询
function displayDiv() 
{ 
  document.getElementById("productSearch_layer").style.display="block"; 
} 
//隐藏商品查询
function hiddenDiv() 
{ 
  document.getElementById("productSearch_layer").style.display="none"; 
}
</script>
<STYLE MEDIA="PRINT">    
	.only_print_view {display:none;}
</STYLE>
<STYLE MEDIA="SCREEN">    
	.only_print_view {display:block;}
</STYLE>
</head>

<body id="body" bgcolor="#FFFFFF">
<OBJECT ID="ReYoPrint" CLASSID="CLSID:5C230622-45E5-4e3c-893C-3BFDDC4DB5E4"  codebase="ReYoPrint.cab" height="0" width="0"></OBJECT>
<script>
  ReYoPrint.MarginLeft=2;	//设置左边边距
  ReYoPrint.MarginRight=2;	//设置右边边距 
  ReYoPrint.MarginTop=2;	//设置上边边距
  ReYoPrint.MarginBottom=2;	//设置下边边距
  ReYoPrint.CopyCount=1;  	//打印份数
  ReYoPrint.PageHeader="";	//页眉
  ReYoPrint.PageFooter="";	//页脚
  ReYoPrint.IsLandScape=1;	//把页面设置为横向1
  //ReYoPrint.ContentURL="http://www.interdrp.com/print.html";
</script>

<div id="productSearch_layer" style="display:none;background:#E9E9E9">
<input type="button" onClick="hiddenDiv()" value="返回">
<iframe class="TBGen" style="top:2px" ID="UploadFiles" src="product_search.jsp" frameborder=0 scrolling=no width="500" height="300"> </iframe>
</div>

<form name="bjsh_form" method="post" action="sh_sh_cgbj.jsp?CaiGouBiaoId=<%=caiGouBiaoId %>">
<table width="100%" cellpadding="2" cellspacing="0" border="0"  bgcolor="<%= tblBorderColor %>">
	<tr bgcolor="#FFFFFF">
		<td colspan="3" class="tdGeneralTop">
		<table width="100%" height="40" cellspacing="0" border="0" 
			cellspacing="2">
			<tr bgcolor="#FFFFFF">
				<td width="73%">
				<div align="center"><%=cgbj.getMingCheng() %> 采购比价单</div></td>
				<td width="27%">单据编号： <%=cgbj.getDanJuBiaoHao()%></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td colspan="3" class="tdGeneral">
		<table width="100%" cellpadding="2" cellspacing="0" border="0" >
			<tr>
				<td width="50%">
					<label align = "left">申购项目：<%=XiangMuManager.getxiangMuByID(cgbj.getXiangMuId()).getMingCheng() %></label>
		        </td>
		        <td width="23%">
		        	<label align = "left">类别：<%=cgbj.getBiaoLeiXingMing() %> </label>
		        </td>
				<td width="27%">
					日期：<%=cgbj.getChuangJianShiJian() %>
				</td>
			</tr>
		</table>
	  </td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td width="2%" class="tdGeneral">
		<div align="center">情况汇总</div>
	  </td>
		<td width="34%" valign="top" class="tdGeneral">
		<table id="testTbl" cellspacing="0" border="0" >
				<tr id="tr0">
				<td width="12" class="tdOnlyRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="96" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="56" id="b11" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="28" id="b11" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="48" id="b11" class="tdOnlyLeftAndRight">
				<div align="center" style="overflow-x:auto;width:35px">&nbsp;</div>
				</td>
		<%
        Iterator cggs_iter1 = cggss.iterator();
        while (cggs_iter1.hasNext()){
        	CaiGouGongSi gs = (CaiGouGongSi)cggs_iter1.next();
        	out.println("<td bgcolor=\"#FFFFFF\" id=\"b11\" class=\"tdOnlyLeftAndRight\" colspan =\"2\">"+					
			        "<div align=\"center\">"+gs.getGongSimingCheng()+"</div>"+
		            "</td>");
        }
        
        //补足默认个数
        for(int indexFactory = 0 ;indexFactory < xFactorysNeed;indexFactory++)
        {
        	out.println("<td bgcolor=\"#FFFFFF\" id=\"b11\" class=\"tdOnlyLeftAndRight\" colspan =\"2\">"+					
			        "<div align=\"center\">"+" &nbsp; "+"</div>"+
		            "</td>");
        }
        %>
		<td class="tdOnlyLeft"><div align="center" style="overflow-x:auto;width:35px">&nbsp;</div></td>
		</tr>
			<tr id="tr0">
				<td width="12" class="tdLeftTop">
				<div align="center">序号</div>
				</td>
				<td width="96" class="tdTop">
				<div align="center">品名</div>
				</td>
				<td width="56" id="b11" class="tdTop">
				<div align="center">规格型号</div>
				</td>
				<td width="28" id="b11" class="tdTop">
				<div align="center">数量</div>
				</td>
				<td width="48" id="b11" class="tdTop">
				<div align="center" style="overflow-x:auto;width:35px">计量单位</div>
				</td>
					<%
        				Iterator cggs_iter2 = cggss.iterator();
       					 while (cggs_iter2.hasNext())
       					 {
        					CaiGouGongSi gs = (CaiGouGongSi)cggs_iter2.next();
        					out.println( "<td class=\"tdGeneral\"><div align=\"center\">报价</div></td><td class=\"tdGeneral\"><div align=\"center\">审价</div></td>");
        				}
        
        				//补足默认个数
        				for(int indexFactory = 0 ;indexFactory < xFactorysNeed;indexFactory++)
        				{
        					out.println( "<td class=\"tdGeneral\"><div align=\"center\">报价</div></td><td class=\"tdGeneral\"><div align=\"center\">审价</div></td>");          
        				}
        				%>
        
			<td class="tdRightTop"><div align="center" style="overflow-x:auto;width:35px">历史价格</div></td>
			</tr>
	 		<%
    			Iterator iter = sps.iterator();
			    int i=1;
    			while (iter.hasNext())
    			{
    				//
    				CaiGouShangPing sp = (CaiGouShangPing)iter.next();
    				int caiGouShangPingId = sp.getCaiGouShangPingId();
    		%>
			<tr id="tr1">
              <td align="center" width="20" class="tdLeft"><div align="center" style="overflow-x:auto;width:20px"><%=i %></div></td>
              <td width="120" class="tdMiddle"><div style="overflow-x:auto;width:150px"><%=sp.getMingCheng() %></div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:100px"><%=sp.getGuiGe() %></div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:50px"><%=sp.getShuLiang() %></div></td>
              <td id="b11" align="center" class="tdMiddle"><div style="overflow-x:auto;width:50px">
                <label><%=sp.getDanWei() %></label>
              </div></td>
              <%
						Iterator iter_gs = cggss.iterator();
						int j = 1;
						while (iter_gs.hasNext()) {
							CaiGouGongSi val = (CaiGouGongSi) iter_gs.next();
							out.println("<td class=\"tdMiddle\"><div align=\"center\">"+ cgbj.getGongSiBaoJia(caiGouShangPingId, val.getGongSiId())+"</div></td>" +
									"<td class=\"tdMiddle\"><div align=\"center\">"+cgbj.getShenHeBoaJia(caiGouShangPingId, val.getGongSiId())+"</div></td>");
							j++;
						}
						
				        //补足默认个数
				        for(int indexFactory = 0 ;indexFactory < xFactorysNeed;indexFactory++)
				        {
							out.println("<td class=\"tdMiddle\"><div align=\"center\">" + "&nbsp;" + "</div></td>" +
							"<td class=\"tdMiddle\"><div align=\"center\">" + "&nbsp;" +"</div></td>");
				        }	
				%>
				<td class="tdRight"><%=sp.getLiShiJiaGe() %></td>
		  	</tr>
			
	        <% 
	        	i++;
	  			} 
	  		%>
	  		
	  		
	  		<!-- 以下是商品不足5时补5 --> 
	 		<%
				for(int indexShangPin = 0;indexShangPin <  xProductorysNeed;indexShangPin++)
				{
    		%>
			<tr id="tr1">
              <td align="center" width="20" class="tdLeft"><div align="center" style="overflow-x:auto;width:20px">&nbsp;</div></td>
              <td width="120" class="tdMiddle"><div style="overflow-x:auto;width:150px">&nbsp;</div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:100px">&nbsp;</div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:50px">&nbsp;</div></td>
              <td id="b11" align="center" class="tdMiddle"><div style="overflow-x:auto;width:50px">
                <label>&nbsp;</label>
              </div></td>
              <%

				        //补足默认个数
				        int shangPinNeedCount = xFactorysNeed + factorys;
				        for(int indexFactory = 0 ;indexFactory < shangPinNeedCount;indexFactory++)
				        {
							out.println("<td class=\"tdMiddle\"><div align=\"center\">" + "&nbsp;" + "</div></td>" +
							"<td class=\"tdMiddle\"><div align=\"center\">" + "&nbsp;" +"</div></td>");
				        }	
				%>
				<td class="tdRight">&nbsp;</td>
		  	</tr>
			
	        <% 
	        	
	  			} 
	  		%>
	  		
	  		<!-- 补足商品结束        --> 
	  		
	  		
			<tr id="trzj">
			<td colspan="5" align="center" class="tdLeft">总价</td>
			<%
				Iterator iter_gs = cggss.iterator();
				int k=1;
       			while (iter_gs.hasNext())
       			{
        			CaiGouGongSi val = (CaiGouGongSi)iter_gs.next();
					out.println("<td class=\"tdMiddle\"><div align=\"center\">"+ val.getZongBaoJia() +"</div></td>" + 
					"<td class=\"tdMiddle\"><div align=\"center\">"+ val.getZongShenHeBaoJia() +"</div></td>");
        			k++;
        		}
       			
		        //补足默认个数
		        for(int indexFactory = 0 ;indexFactory < xFactorysNeed;indexFactory++)
		        {
					out.println("<td class=\"tdMiddle\"><div align=\"center\">"+ "&nbsp;"  +"</div></td>" + 
							"<td class=\"tdMiddle\"><div align=\"center\">"+ "&nbsp;"  +"</div></td>");
		        }
       		 %>
				<td class="tdRight">&nbsp;</td>
			</tr>
			<tr id="trlxr">
			<td colspan="5" align="center" class="tdLeftBottom">联系人(联系方式)</td>
			<%
        		iter_gs = cggss.iterator();
        		while (iter_gs.hasNext())
        		{
        			CaiGouGongSi val = (CaiGouGongSi)iter_gs.next();
        			//int  =m.get("");
        			out.println("<td  id=\"b11\" class=\"tdBottom\" colspan=\"2\"><div align=\"center\" style=\"overflow-x:auto;width:114px\">" +
        			val.getLianXirenHeFangshi()+  
        			" </div></td>");
        		}
		        //补足默认个数
		        for(int indexFactory = 0 ;indexFactory < xFactorysNeed;indexFactory++)
		        {
        			out.println("<td  id=\"b11\" class=\"tdBottom\" colspan=\"2\"><div align=\"center\" style=\"overflow-x:auto;width:114px\">" +
        					"&nbsp;" +  " </div></td>");
		        }
   			 %>
				<td class="tdRightBottom">&nbsp;</td>
			</tr>
		</table>
	  	</td>
	  	<!-- 右边的备注 -->
		<td width="150" valign="top"  class="tdGeneral">
			<div align="center">备注</div>
			<hr/>
			<div style="overflow-x:auto;width:150px"><%=cgbj.getYouBianBeiZhu() %></div>
			
	  	</td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td class="tdGeneral"><span style="width: 12px" >审核意见</span></td>
		<td colspan="2" class="tdGeneral">
		<table width="100%" cellspacing="0" border="0" >
			<tr height="90">
				<td width="24%" class="tdLeftTop"><span
					style="height: 40px; width: 150px; text-align: left;">技术备注：</span></td>
				<td width="76%" class="tdRightTop"><%=cgbj.getXiaMianBeiZhu()%></td>
			</tr>
			<tr height="90" >
				<td class="tdLeft"><span style="width: 150px; height: 21px; text-align: left">项目组意见:</span></td>
				<td class="tdRight"><table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getXiangMuZouYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getXiangMuZouYiJian(), false )%></div></td>
                  </tr>
                </table>
		  </td>
			</tr>
			<tr height="90">
				<td class="tdLeft"><span style="width: 150px; text-align: left;">采购部意见:</span></td>
				<td class="tdRight">
				<table width="100%" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getCaiGouBuYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getCaiGouBuYiJian(), false )%></div></td>
                  </tr>
                </table></td>
			</tr>
			<tr height="90">
				<td class="tdLeft"><span style="width: 150px; text-align: left">比价部意见:</span></td>
				<td class="tdRight">
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getBiJiaBuYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getBiJiaBuYiJian(), false )%></div></td>
                  </tr>
                </table>
			  </td>
			</tr>
			<tr height="90">
				<td class="tdLeft"><span style="width: 150px; text-align: left">中心总经理批示:</span></td>
				<td class="tdRight">
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getZhongXinJingLiYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getZhongXinJingLiYiJian(), false )%></div></td>
                  </tr>
                </table>
			  </td>
			</tr>
			<tr height="90">
				<td class="tdLeftBottom"><span style="width: 150px; text-align: left;">分管总裁批示:</span></td>
				<td class="tdRightBottom">
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getFenGuanZongCaiYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getFenGuanZongCaiYiJian(), false )%></div></td>
                  </tr>
                </table></td>
			</tr>
		</table>
	  </td>
	</tr>
	<tr>
	<td colspan="3" align="right" bgcolor="#FFFFFF" class="tdGeneralBottom">
	 采购员： <%=strCaiGoyYuanName %>
	</td>
	</tr>
</table>
<br />
<label>
<input type="button" name="Submit2" value="打印预览" onClick=ReYoPrint.PrintPreview() class="Noprint">
</label>
<label>
	<%
		if(	pageUser.isShenHeYuan() && cgbj.isShenHeDenDai())
		{
	%>
					<input	type="submit" name="Submit" value="开始审核"/>
		<%} %>
 <input type="button"
	onClick="displayDiv()" value="商品查询" class="Noprint"></label>

</form>

</body>
</html>
